package com.example.securitydemo2.controller;

import com.example.securitydemo2.entity.UserInfo;
import com.example.securitydemo2.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
public class UserInfoController {

    @Autowired
    private UserInfoService service;

    @GetMapping("/get-user")
    public UserInfo getUser(@RequestParam String username){
        return service.getUserInfo(username);
    }

    @GetMapping("/get-all")
    @ResponseBody
//    @PreAuthorize("hasAuthority('USER_FINDALL')")
//    @PreAuthorize("hasRole('ADMIN')")
    public List<UserInfo> getAll(){
        return service.getAll();
    }
}
